// run: $exec < input
#include <cstdio>

int h, m, s, a;

int main()
{
	for (int ti = 1; ~scanf("%d:%d:%d",&h,&m,&s); ti++) {
		scanf("%d",&a); a *= 120;
		int t1 = 3600 * h + 60 * m + s;
		int a1, a2, a3, inf = 1e9;
		for(int i = 0; i < 12; i++){
			int hh = 3600 * i - a;
			int mm = hh / 660;
			int ss = hh % 660 / 11;
			int t2 = i * 3600 + mm * 60 + ss;
			int dt = t2 - t1;
			if (dt <= 0) dt += 3600 * 12;
			if (dt < inf){ a1 = i; a2 = mm; a3 = ss; inf = dt; }
			hh = 3600 * i + a;
			mm = hh / 660;
			ss = hh % 660 / 11;
			t2 = i * 3600 + mm * 60 + ss;
			dt = t2 - t1;
			if (dt <= 0) dt += 3600 * 12;
			if (dt < inf) { a1 = i; a2 = mm; a3 = ss; inf = dt; }
		}
		printf("Case #%d: %02d:%02d:%02d\n", ti, a1, a2, a3);
	}
}

